/********************************************************************************
 *      Copyright:  (C) 2020 makun<1394987689@qq.com>
 *                  All rights reserved.
 *
 *       Filename:  conf.h
 *    Description:  This head file 
 *
 *        Version:  1.0.0(2020年07月08日)
 *         Author:  makun <1394987689@qq.com>
 *      ChangeLog:  1, Release initial version on "2020年07月08日 23时18分11秒"
 *                 
 ********************************************************************************/

#ifndef __CONF_H_
#define __CONF_H_

#include <stdio.h>


#define DEF_BORKER_CLIENTID   "12345|securemode=3,signmethod=hmacsha1,timestamp=789|"
#define DEF_BORKER_USERNAME "SHT20&a1ix9D9Mm1z"
#define DEF_BORKER_PASSWD    "1208b575070251f453e6d1db5badf952aaa4c1bf"
#define DEF_BORKER_HOSTNAME "a1ix9D9Mm1z.iot-as-mqtt.cn-shanghai.aliyuncs.com"
#define DEF_BORKER_PORT    1883
#define DEF_BORKER_SUBTOPIC     "/sys/a1ix9D9Mm1z/SHT20/thing/service/property/set"
#define DEF_BORKER_PUBTOPIC     "/sys/a1ix9D9Mm1z/SHT20/thing/event/property/post"
#define DEF_QOS                 0
#define DEF_BROKER_KEEPALIVE      60

#define DEF_METHOD      "thing.service.property.set"
#define  DEF_ID      "569389422"
#define  DEF_IDENTIFIER "data"
#define  DEF_VERSION    "1.0.0"

typedef struct  mqtt_ctx_s
{
    char    hostname[128];  /*  MQTT broker server name   */
    int     port;           /*  MQTT broker listen port   */
    char    username[64];   /*  username */
    char    passwd[64];     /*  password  */
    char    clientid[128];  /*   production ID */
    char    pubTopic[256];  /*  Publisher topic   */
    int     Qos;         /*  Publisher Qos  */
    char    subTopic[256];
    int     keepalive;      /*  MQTT broker send PING message to subsciber/publisher keepalive timeout<seconds> */

    char method[64];
    char id[32];
    char identifier[32];
    char version[32];

}mqtt_ctx_t;


int gain_mqtt_conf(char *path_ini, mqtt_ctx_t *mqtt);
int set_mqtt_conf(char *path_ini, char *host, int port, char *clientid, char *user, char *passwd, char *topic);







#endif

